// 全球购-产品列表
function qqg_pro_list() {
    let mockData = Mock.mock({
        "prolist|8": [{
            'img': "@image('214x274',#eac7ce)",
            'title': "@ctitle(5, 10)",
            'sellprice|100-200.2': 239.00,
            'manjian|0-1': 0,
            'baoyou|0-1': 0
        }],
        "catelist": ['休闲日常', '秋冬新品', '母婴专场', '职场丽人', '红人穿搭'],
        "sortIds":["83","84","85","86","87"],
    });
    new Vue({
        el: '#qqg_pro_list',
        data() {
            return {
                prolist: null,
                catelist: null,
                topnavlist:{},
                where: {
                    pages: 0,
                    brandId: '',
                    sortId: 0,
                    keyword: '',
                    price: '',
                    minPrice: '',
                    maxPrice: '',
                    sales: '',
                },
                prolist:"",
                titalCount:"",
                adList:null,
            }
        },
        methods: {
            getData() {
                this.prolist = mockData.prolist;
                this.catelist = mockData.catelist;
                this.sortIds=mockData.sortIds;

                //this.getList();
            },
            listen: function(data) {
                // 翻页事件
                alert('当前页码：' + data);
            },
            sortIdmmmmm(id){
                this.where.sortId=id;
                this.getList();
            },
            qqgPaixu(type, minprice, maxpice) {
                if (type == 3) {
                    if(this.where.price.length==0){
                        this.where.price=0;
                    }else{
                        this.where.price=(this.where.price == 0) ? 1:0;
                    }
                    this.where.sales = '';
                } else if (type == 2) {
                    this.where.price = '';
                    this.where.sales = 1;
                } else {
                    this.where.price = '';
                    this.where.sales = '';
                }
                this.where.minPrice = minprice;
                this.where.maxPrice = maxpice;
                this.getList();
            },

            getAdInfo(){
                var that = this;
                axios({
                    method: 'get',
                    url: urlParam.domain() + '/api/ad/adOnePC',
                    params:{
                        adPostionId:40,
                    },
                    responseType: 'stream',
                }).then(function(response) {
                    that.adList = response.data.data.list;
                    that.where.sortId=response.data.data.list[0].href;
                    that.getList();
                });
            },
            getList(){
                var that = this;
                //that.where.keyword=that.url_params.keyword==null?'':that.url_params.keyword;
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/productInfo/productSearch',
                    responseType: 'stream',
                    params: this.where
                }).then(function(response) {
                    that.prolist = response.data.data.products;
                    that.titalCount =getPageCount(response.data.data.titalCount,10)
                });
            },


        },
        created() {
            this.getData();
            this.getAdInfo();
        },
        components: {
            'pro-list': base_product_list,
            'cate-type': cate_type,
            'paixu': paixu,
        }
    })
}